{include file="common/header" /}
<style>
    body {
        background-color: #ffffff;
    }
</style>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="required" lay-reqtext="用户名不能为空" placeholder="请输入用户名" class="layui-input" value="{:session('admin_user')}" readonly="">
            
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label ">密码</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input" name="password"  value="" autocomplete="off" placeholder="请输入密码">
            <tip></tip>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label ">再次输入密码</label>
        <div class="layui-input-block">
            <input type="password" class="layui-input" name="repassword"  value="" autocomplete="off" placeholder="请再次输入密码">
            <tip></tip>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>

<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            // var index = layer.load(1, {
            //     shade: [0.3,'#000'] //0.1透明度的白色背景
            // });
            var data = data.field;
            $.ajax({
                url:"{:url('Admin/updatePwd')}",
                data:data,
                type:'post',
                dataType:'json',
                success:function(res){
                    // layer.close(index);
                    // console.log(res)
                    // return false
                    if(res.errcode != 1){
                        layer.msg(res.message,{icon: 2,time: 2000},function(){
                            layer.close(index);
                        })
                    }else{
                        layer.msg(res.message,{icon: 1,time: 1000},function () {
                            window.location.href = "{:url('index/welcome')}";
                        })
                    }
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg('网络失败，请刷新页面后重试!',{icon: 2,time: 2000})
                }
            });

            return false;
        });

    });
</script>
</body>
</html>